/**
 * @program: LeetCode
 * @description: LeetCode : 剑指 Offer II 052. 展平二叉搜索树
 * @author: WXY
 * @create: 2023-01-03 10:23
 * @Version 1.0
 **/
public class offer_seventeen3_ {
    public TreeNode increasingBST(TreeNode root) {
        process(root);
        return pre.right;
    }

    private void process(TreeNode root) {
        if (root == null) return;
        process(root.left);
        node.right = new TreeNode(root.val);
        node = node.right;
        process(root.right);
    }

    public class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode() {
        }

        TreeNode(int val) {
            this.val = val;
        }

        TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }    TreeNode pre = new TreeNode(), node = pre;




}
